<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        console.log('-----1.定义一个函数，求任意数字的和-----')
        var arr1 = [1, 3, 4, 5, 6, 345, 4, 53]
        var sum = arr1.reduce(function (prev, next) {
            return prev + next
        })
        console.log(arr1)
        console.log("和为：" + sum)

        console.log('-----2.求一个三位数的百位，十位和个位-----')

        function func2(num) {
            console.log("百位：" + parseInt(num / 100))
            console.log("十位：" + parseInt(num / 10 % 10))
            console.log("个位：" + parseInt(num % 10))
        }
        func2(314)

        console.log('-----3.找出0-100之间的所有偶数-----')
        var i_String = 0;
        for (var i = 0; i <= 100; i++) {
            if (i % 2 == 0 && i != 0) {
                i_String += i + ","
            }
        }
        console.log(i_String)

        console.log('-----4.编写一个函数，计算三个数字的大小，按从小到大顺序输出-----')

        function func4(num1, num2, num3) {
            var flag = 0
            if (num1 > num2) {
                flag = num1;
                num1 = num2;
                num2 = flag
            }
            if (num1 > num3) {
                flag = num1;
                num1 = num3;
                num3 = flag;
            }
            if (num2 > num3) {
                flag = num2;
                num2 = num3;
                num3 = flag;
            }
            console.log(num1 + '<' + num2 + '<' + num3)
        }
        func4(100, 3, 56)

        console.log('------删除字符串中的重复字符-----')
    </script>
</body>

</html>